package data;

import java.sql.Time;
import java.util.Collection;

import util.TimeUtil;

public class TimeStockThread extends Thread{

	int i=0;
	@Override
	public void run() {
		while(true){
			try {
				TimeStock timeStock = LoadData.getTimeStock("sz399001");
				String string = StockURLDataBuffer.getUrlData(timeStock.getCode());
				String[] s = string.split(",");
				String[] time = s[31].split(":");
				Time t = new Time(Integer.parseInt(time[0]),
						Integer.parseInt(time[1]),
						Integer.parseInt(time[2]));
				if(t.equals(timeStock.getTime())){
					Thread.sleep(Constant.PER_STOCK_TIME);
					continue;
				}
				
				Collection<TimeStock> tss = LoadData.getStockList().values();
				for (TimeStock ts : tss) {
					ts.refresh();
				}
				Thread.sleep(Constant.PER_STOCK_TIME);
			} catch (InterruptedException e1) {
				e1.printStackTrace();
			}catch (Exception e1) {
				e1.printStackTrace();
			}
		}
	}
}
